//
//  BKUserOrderInfoViewCell.m
//  bestkeep
//
//  Created by windCould on 16/11/7.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKUserOrderInfoViewCell.h"
#import "BKMyOrderStatusCount.h"
@implementation BKUserOrderInfoViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setUpViews];
    }
    return self;
}

-(void)setUpViews
{
    NSArray * imgStrArr = @[@"BK_My_待付款icon",@"BK_My_待发货icon",@"BK_My_待收货icon",@"BK_My_待评价icon",@"BK_My_退换货icon"];;
    NSArray * itemTitleArr = @[@"待付款",@"待发货",@"待收货",@"待评价",@"退换货"];
    self.array = [NSMutableArray array];
    for (int i = 0; i < imgStrArr.count; i++) {
        
        BKCusImgAndLabbtn * btn = [[BKCusImgAndLabbtn alloc]initWithFrame:CGRectMake(i * (ScreenWidth/5.0), 5, (ScreenWidth/5.0), 65)];
        btn.imgNameStr = imgStrArr[i];
        btn.itemTitle = itemTitleArr[i];
        btn.orderStaus = i;
        [btn addTarget:self action:@selector(orderStatusBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:btn];
        [self.array addObject:btn];
        
    }
    
}

-(void)fillData:(id)data
{
   BKMyOrderStatusCount *model = data;
    
    
    for (BKCusImgAndLabbtn *btn in self.array) {
        if (btn.orderStaus ==0) {
            btn.bageStr = model.wait_pay;
            
        }
        if (btn.orderStaus ==1) {
            btn.bageStr = model.paid;
        }
        if (btn.orderStaus ==2) {
           
            btn.bageStr = model.wait_receive;
        }
        if (btn.orderStaus ==3) {
        
            btn.bageStr = model.wait_evaluation_order;

        }
            }
    

}
+(CGFloat)calculateHeightWithData:(id)data
{
    return 65;
}


-(void)orderStatusBtnClick:(BKCusImgAndLabbtn *)btn
{
    
    switch (btn.orderStaus) {
        case 0:{
            
            if ([self.orderStatusDelegate respondsToSelector:@selector(bKUserOrderInfoViewCell:goToAllOrders:)]) {
                
                [self.orderStatusDelegate bKUserOrderInfoViewCell:self goToAllOrders:btn.orderStaus];
            }
        
            break;
        }
        case 1:{
            
            if ([self.orderStatusDelegate respondsToSelector:@selector(bKUserOrderInfoViewCell:goToWaitToPayOrders:)]) {
                
                [self.orderStatusDelegate bKUserOrderInfoViewCell:self goToWaitToPayOrders:btn.orderStaus];
            }
            break;
        }
        case 2:{
            
            if ([self.orderStatusDelegate respondsToSelector:@selector(bKUserOrderInfoViewCell:goToWaitToReceviewOrders:)]) {
                
                [self.orderStatusDelegate bKUserOrderInfoViewCell:self goToWaitToReceviewOrders:btn.orderStaus];
            }
            
            break;
        }
        case 3:{
            
            if ([self.orderStatusDelegate respondsToSelector:@selector(bKUserOrderInfoViewCell:goToWaitToEvlotionOrders:)]) {
                
                [self.orderStatusDelegate bKUserOrderInfoViewCell:self goToWaitToEvlotionOrders:btn.orderStaus];
            }
            
            break;
        }
        case 4:{
            
            if ([self.orderStatusDelegate respondsToSelector:@selector(bKUserOrderInfoViewCell:goToReturnAndExchangerders:)]) {
                
                [self.orderStatusDelegate bKUserOrderInfoViewCell:self goToReturnAndExchangerders:btn.orderStaus];
            }
                        
            break;
        }

        default:
            break;
    }
    

}




@end
